﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TanWeb.Helpers;
using TanWeb.Models.Entities;
using TanWeb.Controllers.Business;
using Newtonsoft.Json;
using log4net;

namespace TanWeb.Controllers
{
    public class HomeController : Controller
    {
        #region Private Variable Declared
        /// <summary>
        /// Log4net 変数
        /// </summary>
        protected static readonly ILog logger = LogManager.GetLogger(typeof(Controller));
        #endregion

        public ActionResult Index()
        {
            logger.Info("Start Controller: Home; Action: Index");

            HomeBusiness business = new HomeBusiness();
            List<ProductProfile> lstProductProfile = new List<ProductProfile>();

            try
            {
                List<MenuItem> menuItems = business.GetMenuItems();
                lstProductProfile = business.GetProductInfo();
                Session[Constants.SS_LISTMENUITEM] = menuItems;
            }
            catch (Exception ex)
            {
                logger.Info("Error Controller: Home; Action: Index");
            }

            logger.Info("End Controller: Home; Action: Index");

            return View(Constants.PAGE_HOME_INDEX, lstProductProfile);
        }

        public ActionResult Introduction()
        {
            logger.Info("Start Controller: Home; Action: Introduction");

            HomeBusiness business = new HomeBusiness();
            List<ProductProfile> lstProductProfile = new List<ProductProfile>();

            try
            {
                List<MenuItem> menuItems = business.GetMenuItems();
                lstProductProfile = business.GetProductInfo();
                Session[Constants.SS_LISTMENUITEM] = menuItems;
            }
            catch (Exception ex)
            {
                logger.Info("Error Controller: Home; Action: Introduction");
            }

            logger.Info("End Controller: Home; Action: Introduction");

            return View(Constants.PAGE_HOME_INTRODUCTION);
        }
    }
}
